package com.bjc.gmall.service.impl;



import com.alibaba.dubbo.config.annotation.Service;
import com.bjc.gmall.bean.UserAddress;
import com.bjc.gmall.service.UserService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

/**
 * @program: dubbo-study
 * @description:
 * @author: bjc
 * @create: 2020-07-19 11:41
 * 一.将服务提供者注册到注册中心（暴露服务）
 *      1.导入dubbo依赖(2.6.2)  操作zookeeper的客户端（curator）
 *      2.配置服务提供者
 * 二.让服务消费者去注册中心订阅服务提供者的服务地址
 */
@Service //暴露服务
@Component
public class UserServiceImpl implements UserService {

    @HystrixCommand
    @Override
    public List<UserAddress> getUserAddressList(String userId) {
        System.out.println("UserServiceImpl....3....");
        UserAddress address1 = new UserAddress(1, "南京市浦口区", "1", "卜京城", "1771030XXXX", "Y");
        UserAddress address2 = new UserAddress(2, "淮南市凤台县", "1", "陈梦", "1731853XXXX", "Y");
        if (Math.random()>0.5){
            throw new RuntimeException();
        }
        return Arrays.asList(address1,address2);
    }
}
